<?php
class Search_Facet extends CI_Controller
{
	function __construct()
	{
		parent::__construct();
		$this->load->library('zend', 'Zend/Search/Lucene');
		$this->load->library('zend');
		$this->zend->load('Zend/Search/Lucene');

	}

	function index()
	{
		$index = new Zend_Search_Lucene('index/perguntas_index');
		$q = mysql_real_escape_string( $_GET['q'] );
		$query =  $q;
		$hits = $index->find($query);
		foreach($hits as $hit)
		{
			$result = addslashes($hit->titulo);
			$html = preg_replace("/(" . $q . ")/i", "<span style=\"font-weight:bold\">\$1</span>", $result);
			echo "<li onselect=\"this.setText('$result');\">$html</li>\n";
		}
	}
}
?>
